#ifndef _BIOS_INFO_H_
#define _BIOS_INFO_H_
#include <string>
#include "types.h"

class BiosInfos {
public:
    BiosInfos() : _length(0), _startAddressSegment(0), _romSize(0),
                  _characteristics{0}, _characteristicsExtensionBytes(0),
                  _majorRelease(0xFF), _minorRelease(0xFF),
                  _ecfMajorRelease(0xFF), _ecfMinorRelease(0xFF),
                  _extendedBiosROMSize(16) {}

    BiosInfos(UINT8 len, const std::string &vendor,
              const std::string &version, UINT16 addrSeg,
              const std::string &date, UINT8 romSize, UINT64 character) : 
              _length(len), _vendor(vendor), _version(version),
              _startAddressSegment(addrSeg), _releaseDate(date),
              _romSize(romSize), _characteristics(character), 
              _characteristicsExtensionBytes(0), _majorRelease(0xFF), _minorRelease(0xFF),
              _ecfMajorRelease(0xFF), _ecfMinorRelease(0xFF),
              _extendedBiosROMSize(16){}
    void setGeneral(UINT8 len, const std::string &vendor,
                    const std::string &version, UINT16 addrSeg,
                    const std::string &date, UINT8 romSize,
                    UINT64 character);
    void    setCharacteristicsExtensionBytes(UINT16 ceb) { _characteristicsExtensionBytes = ceb; }
    
    void    setExtendedBiosROMSize(UINT16 romSize) { _extendedBiosROMSize = romSize; }
    
    void    setBiosMajorAndMinorRelease(UINT8 major, UINT8 minor) { 
            _majorRelease = major;
            _minorRelease = minor;
    }
    // ecf: Embedded Controller Firmware
    void    setEcfMajorAndMinorRelease(UINT8 major, UINT8 minor) { 
            _ecfMajorRelease = major;
            _ecfMinorRelease = minor;
    }

    void    print() const;

protected:
    void    printBiosRuntimeSize(UINT32 code) const;

    void    printBiosRomSize(UINT8 code1, UINT16 code2) const;

    void    prinMemorySize(const char *attr, UINT64 code, int shift) const;

    void    printBiosCharacteristics(UINT64 code) const;

    void    PrintBiosCharacteristicsX1(UINT8 code) const;
    void    PrintBiosCharacteristicsX2(UINT8 code) const;

private:
    // 2.0 +
    UINT8       _length;
    std::string _vendor;
    std::string _version;
    UINT16      _startAddressSegment;
    std::string _releaseDate;
    UINT8       _romSize;
    UINT64      _characteristics;
    // 2.4 +
    UINT16      _characteristicsExtensionBytes;
    UINT8       _majorRelease;
    UINT8       _minorRelease;
    // ecf: Embedded Controller Firmware
    UINT8       _ecfMajorRelease;
    UINT8       _ecfMinorRelease;
    // 3.1 +
    UINT16      _extendedBiosROMSize;
};

#endif